<template>
  <div class="nav-header">
    <el-icon class="fold-menu" @click="handleFoldClick">
      <component :is="isFold ? 'fold' : 'expand'"></component>
    </el-icon>
    <div class="content">
      <breadCrumb :bread-crumbs="breadCrumbs"></breadCrumb>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, computed, defineEmits } from 'vue'
import { useStore } from '@/store'
import { useRoute } from 'vue-router'
import breadCrumb from './c-cpns/bread-crumb.vue'
import { pathMapBreadcrumbs } from '@/utils/map-menus'
const store = useStore()
const route = useRoute()
const emits = defineEmits(['foldChange'])
// 折叠/展开
const isFold = ref(false)
const handleFoldClick = () => {
  isFold.value = !isFold.value
  emits('foldChange', isFold.value)
}
// 面包屑
const breadCrumbs = computed(() => {
  const userMenus = store.state.login.userMenuInfo
  const currentPath = route.path
  return pathMapBreadcrumbs(userMenus, currentPath)
})
</script>
<style scoped lang="less">
.nav-header {
  display: flex;
  width: 100%;
  .fold-menu {
    font-size: 25px;
    cursor: pointer;
  }
  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0 20px;
  }
}
</style>
